export default {
	is_copy(val) {
		let result;
		// #ifndef H5
		uni.setClipboardData({
			data: val, //要被复制的内容
			success: () => { //复制成功的回调函数
				result = true;
			},
			fail: () => {
				result = false;
			}
		});
		// #endif

		// #ifdef H5 
		let textarea = document.createElement("textarea")
		textarea.value = val
		textarea.readOnly = "readOnly"
		document.body.appendChild(textarea)
		textarea.select() // 选中文本内容
		textarea.setSelectionRange(0, val.length)
		result = document.execCommand("copy")
		textarea.remove()
		// #endif

		uni.showToast({
			icon: 'none',
			duration: 3000,
			title: `${result ? '复制成功' :'复制失败'}`
		});
	},

	goBack() {
		let canNavBack = getCurrentPages();
		let numberOfEntries = null;
		//#ifdef H5
		numberOfEntries = window.history.length;
		// #endif
		if (canNavBack && canNavBack.length > 1) {
			uni.navigateBack({
				delta: 1
			});
		} else if (numberOfEntries && numberOfEntries > 1) {
			history.back();
		} else {
			uni.switchTab({
				url: "/pages/my/my"
			})
		}
	}
};
